package edu.ntu.cloudroid.nongui.com;

import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import com.sun.xacml.attr.DoubleAttribute;
import com.sun.xacml.attr.StringAttribute;
import com.sun.xacml.ctx.Attribute;

import edu.ntu.cloudroid.model.policy.PolicyInfo;
import edu.ntu.cloudroid.xacml.XACMLStrings;

/**
 * @author anhdinh
 * Include the filtering function in the request. This is to enable
 * direct request from the client to the datastore, bypassing XACML
 */
public class VitalRequestWithFilteringFunction extends RequestNoInputs{

	private double longitude=-1, latitude=-1;	
	private PolicyInfo policy;
	
	public VitalRequestWithFilteringFunction(String requesterID,
			PolicyInfo policy) {
		super(requesterID);
		this.policy = policy;
	}
	
	
	public PolicyInfo getPolicy(){
		return this.policy;
	}
			
	@Override
	public List<Attribute> getInputAttributes() throws Exception{
		List<Attribute> list = new ArrayList<Attribute>();
		
		 // add the subject's latitude
	      list.add(new Attribute(new URI(XACMLStrings.ATTR_Latitude), null,
	            null, new DoubleAttribute(latitude)));

	      // add the subject's longitude
	      list.add(new Attribute(new URI(XACMLStrings.ATTR_Longitude), null,
	            null, new DoubleAttribute(longitude)));	      	     
		return list;
	}


	public double getLongtitude() {
		return longitude;
	}


	public double getLatitude() {
		return latitude;
	}

	
}
